#include<func.h>
//使用NODEFER标志后，可不断重入，可以自己打断自己
void sigfunc(int signum,siginfo_t *p,void *p1)
{
    printf("befer sleep,sig %d is coming\n",signum);
    sleep(5);
    printf("after sleep,sig %d is coming\n",signum);
}

int main()
{
    struct sigaction act;//定义结构体
    bzero(&act,sizeof(act));//清空
    act.sa_sigaction =sigfunc; //把信号处理函数赋给sa_sigaction
    act.sa_flags=SA_SIGINFO|SA_NODEFER;//标识sa_sigaction生效
    int ret=sigaction(SIGINT,&act,NULL);
    ERROR_CHECK(ret,-1,"sigaction");
    bzero(&act,sizeof(act));//清空
    act.sa_sigaction =sigfunc; //把信号处理函数赋给sa_sigaction
    act.sa_flags=SA_SIGINFO|SA_NODEFER;//标识sa_sigaction生效
    ret=sigaction(SIGQUIT,&act,NULL);
    ERROR_CHECK(ret,-1,"sigaction");
    while(1);
    return 0;
}